<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('广告主数据列表')"/>
</head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            广告主ID：<input type="text" name="id"/>
                        </li>

                        <li>
                            广告主账户名称：<input type="text" name="name"/>
                        </li>

                        <!--<li>-->
                            <!--联系邮箱：<input type="text" name="email"/>-->
                        <!--</li>-->

                        <!--<li>-->
                            <!--&ensp;&ensp;联系人：<input type="text" name="contacter"/>-->
                        <!--</li>-->

                        <!--<li>-->
                            <!--手机号码：<input type="text" name="phonenumber"/>-->
                        <!--</li>-->
                        <li>
                            公司名称：<input type="text" name="company"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()">
                                <i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()">
                                <i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.sync()" shiro:hasPermission="dsp:data:add">
                <i class="fa fa-rocket"></i> 批量同步
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="dsp:data:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var viewFlag = [[${@permission.hasPermi('dsp:data:view')}]];
    var removeFlag = [[${@permission.hasPermi('dsp:data:remove')}]];

    var prefix = ctx + "dsp/data/advertiser";

    $("#form-advertiser-edit").validate({
        rules:{
            xxxx:{
                required:true,
            },
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.sync(prefix + "/sync");
        }
    }

    /**
     * 列内容格式化处理
     * @param value
     * @param row
     * @param index
     * @param col
     * @returns {string}
     */
    function colFormatter(value, row, index, col) {
        var values = row[col];
        var span = document.createElement('span');
        span.setAttribute('title', values);
        span.innerHTML = row[col];
        return span.outerHTML;
    }

    function formatter(value, row, index) {
        return '<a href="#" onclick="detail(\'' + row.id + '\')">' + value + '</a>';
    }

    /*广告主数据列表-详细*/
    function detail(id, name) {
        var url = prefix + '/detail/' + id;
        console.log(id, name);
        createMenuItem(url, name);
    }

    $(function () {
        var options = {
            url: prefix + "/dataList",
            exportUrl: prefix + "/exportAdvertiser",
            updateUrl: prefix + "/edit/{id}",
            syncUrl: prefix + "/sync",
            modalName: "广告主数据",
            search: false,
            showExport: false,
            uniqueId: 'id',
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'name',
                    title: '广告主账户名称',
                    sortable: true,
                    width: 400,
                    class: 'colStyle',
                    formatter: formatter
                },
                {
                    field: 'id',
                    title: '广告主账户ID',
                    sortable: true,
                    formatter: formatter
                },
                {
                    field: 'contacter',
                    title: '联系人',
                    sortable: false
                },
                {
                    field: 'phonenumber',
                    title: '手机号码',
                    sortable: false
                },
                {
                    field: 'email',
                    title: '联系邮箱',
                    sortable: false
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-primary btn-xs ' + viewFlag + '" href="#" onclick="detail(\'' + row.id +'\', \'' + row.name + '\')"><i class="fa fa-eye"></i>&nbsp;查看</a> ');
                        actions.push('<a class="btn btn-success btn-xs ' + viewFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-camera"></i>可视化</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });


</script>
</body>
</html>